
module.exports = app => {

    return class GrowController extends app.Controller {

        async index() {
            let course = await this.service.course.list();
            await this.ctx.render('study/index.js', {
                course
            });
        }

        async statistics() {
            await this.ctx.render('study/statistics/index.js');
        }

        async knowledge() {
            let params = this.ctx.request.query;
            let courseId = params.courseId;
            let type = params.type;

            //普遍错题 专项巩固
            //获取知识点
            if (type == 1 || type == 2){
                //1. 获取教材  http://192.168.1.112:8084/gradeCourse/getMaterial?CourseId=fc2e0c0abe2f418cb42a50c954655599&studentId=6ad3aea3226c41c89a4e8c1085994719
                //2. 获取章节 http://192.168.1.112:8084/charpter/getCharpter?materialId=2dd0480e-80e0-4766-843c-3560a665db5e
                let point = await this.service.knowledge.point({
                    courseId,
                    type
                });

                await this.ctx.render('study/knowledge/index.js', {
                    courseId,
                    point,
                    type
                });
            }else{
                //个人错题 随机练习
                //直接做题
                await this.ctx.redirect(`/study/practice?type=${type}&courseId=${courseId}`);
            }
        }




    };
};
